//  [10/11/2013 OMEGA] created


#include <QtWidgets/QWidget>
#include <QtWidgets/QSplitter>
#include <QtWidgets/QBoxLayout>
#include "DuelGUIECommon.h"
#include "DuelGUIEEditPanel.h"
#include "DuelGUIEEditView.h"
#include "DuelGUIEEditPanelContainer.h"



DGUIEEditPanelContainer::DGUIEEditPanelContainer( DGUIEEditView* parent ) :
	mParent(parent)
{
	setMinimumSize(QSize(70,70));
}

DGUIEEditPanelSingleContainer::DGUIEEditPanelSingleContainer( DGUIEEditView* parent ) :
	DGUIEEditPanelContainer(parent)
{
	QHBoxLayout* layout = new QHBoxLayout(this);
	layout->setMargin(0);
	mPanel = new DGUIEEditPanel(QString("__Single_Panel"),this);
	mViewList.push_back(mPanel);
	layout->addWidget(mPanel);
}

DGUIEEditPanelSingleContainer::~DGUIEEditPanelSingleContainer()
{
	delete mPanel;
}

DGUIEEditPanelDualContainer::DGUIEEditPanelDualContainer( DGUIEEditView* parent ) :
	DGUIEEditPanelContainer(parent)
{
	QHBoxLayout* mainLayout = new QHBoxLayout(this);
	mainLayout->setMargin(0);

	QWidget* lContainer = new QWidget(this);
	QHBoxLayout* llayout = new QHBoxLayout(lContainer);
	llayout->setMargin(0);
	mLeftPanel = new DGUIEEditPanel(QString("__Dual_Panel_Left"),this);
	llayout->addWidget(mLeftPanel);

	QWidget* rContainer = new QWidget(this);
	QHBoxLayout* rlayout = new QHBoxLayout(rContainer);
	rlayout->setMargin(0);
	mRightPanel = new DGUIEEditPanel(QString("__Dual_Panel_Right"),this);
	rlayout->addWidget(mRightPanel);

	QSplitter* splitter = new QSplitter(this);
	splitter->setOrientation(Qt::Horizontal);

	splitter->addWidget(lContainer);
	splitter->addWidget(rContainer);

	mViewList.push_back(mLeftPanel);
	mViewList.push_back(mRightPanel);

	mainLayout->addWidget(splitter);
}

DGUIEEditPanelDualContainer::~DGUIEEditPanelDualContainer()
{
	delete mLeftPanel;
	delete mRightPanel;
}

DGUIEEditPanelQuadContainer::DGUIEEditPanelQuadContainer( DGUIEEditView* parent ) :
	DGUIEEditPanelContainer(parent)
{
	QHBoxLayout* mainLayout = new QHBoxLayout(this);
	mainLayout->setMargin(0);

	QWidget* upContainer = new QWidget(this);
	QHBoxLayout* upLayout = new QHBoxLayout(upContainer);
	upLayout->setMargin(0);
	QSplitter* upSplitter = new QSplitter(this);
	upSplitter->setOrientation(Qt::Horizontal);
	// init upper region.
	{
		QWidget* uplContainer = new QWidget(upContainer);
		QHBoxLayout* upllayoupt = new QHBoxLayout(uplContainer);
		upllayoupt->setMargin(0);
		mTLPanel = new DGUIEEditPanel(QString("__Quad_Panel_TopLeft"),this);
		upllayoupt->addWidget(mTLPanel);

		QWidget* uprContainer = new QWidget(upContainer);
		QHBoxLayout* uprlayoupt = new QHBoxLayout(uprContainer);
		uprlayoupt->setMargin(0);
		mTRPanel = new DGUIEEditPanel(QString("__Quad_Panel_TopRight"),this);
		uprlayoupt->addWidget(mTRPanel);

		upSplitter->addWidget(uplContainer);
		upSplitter->addWidget(uprContainer);
	}

	QWidget* lowContainer = new QWidget(this);
	QHBoxLayout* downLayout = new QHBoxLayout(lowContainer);
	downLayout->setMargin(0);
	QSplitter* lowSplitter = new QSplitter(this);
	lowSplitter->setOrientation(Qt::Horizontal);
	// init lower region.
	{
		QWidget* lowlContainer = new QWidget(lowContainer);
		QHBoxLayout* lowllayout = new QHBoxLayout(lowlContainer);
		lowllayout->setMargin(0);
		mBLPanel = new DGUIEEditPanel(QString("__Quad_Panel_BottomLeft"),this);
		lowllayout->addWidget(mBLPanel);

		QWidget* lowrContainer = new QWidget(lowContainer);
		QHBoxLayout* lowrlayolowt = new QHBoxLayout(lowrContainer);
		lowrlayolowt->setMargin(0);
		mBRPanel = new DGUIEEditPanel(QString("__Quad_Panel_BottomRight"),this);
		lowrlayolowt->addWidget(mBRPanel);


		lowSplitter->addWidget(lowlContainer);
		lowSplitter->addWidget(lowrContainer);
	}
	QSplitter* mainSplitter = new QSplitter(this);
	mainSplitter->setOrientation(Qt::Vertical);

	mainSplitter->addWidget(upSplitter);
	mainSplitter->addWidget(lowSplitter);


	mViewList.push_back(mTLPanel);
	mViewList.push_back(mTRPanel);
	mViewList.push_back(mBLPanel);
	mViewList.push_back(mBRPanel);

	mainLayout->addWidget(mainSplitter);
}

DGUIEEditPanelQuadContainer::~DGUIEEditPanelQuadContainer()
{
	delete mTLPanel;
	delete mTRPanel;
	delete mBLPanel;
	delete mBRPanel;
}
